<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/


$router->get('/', function () use ($router) {
    return '建材';
});

$router->options('{path:.*}', function () {
    return response('', 200);
});

//H5接口
$router->group(['prefix' => 'api', 'namespace' => 'Api'], function () use ($router) {
    $router->get('/goods_class', 'CommodityController@goodsClass');
    $router->get('/goods_list', 'CommodityController@goodsList');
    $router->post('/create_order', 'CommodityController@createOrder');
    $router->options('{path:.*}', function () {
//        header('Access-Control-Allow-Origin:*');
//        header('Access-Control-Allow-Methods:OPTIONS,POST,GET,PUT,DELETE');
//        header('Access-Control-Allow-Headers:requesttype,x-requested-with,content-type,x-csrf-token,x-csrf-token,x-requested-with,origin,x-custom-header');
        return response('', 200);
    });

});

//后台
$router->group(['prefix' => 'admin', 'namespace' => 'Admin'], function () use ($router) {
    $router->get('/order_list', 'OrderController@orderLits');
    $router->get('/order_detail/{id}', 'OrderController@orderDetail');
    $router->post('/login', 'OrderController@login');
    $router->get('/daoru', 'OrderController@daoru');


    $router->options('{path:.*}', function () {
//        header('Access-Control-Allow-Origin:*');
//        header('Access-Control-Allow-Methods:OPTIONS,POST,GET,PUT,DELETE');
//        header('Access-Control-Allow-Headers:requesttype,x-requested-with,content-type,x-csrf-token,origin,x-custom-header');
        return response('', 200);
    });

});


//小程序接口
$router->group(['namespace' => 'Api', 'middleware' => 'auth'], function () use ($router) {

});

$router->group(['namespace' => 'Api'], function () use ($router) {
    $router->post('/upload', 'UploadController@upload');//图片上传
});






